package org.me.SendSMS.adapter;

import java.util.ArrayList;
import java.util.List;

import org.me.SendSMS.R;
import org.me.SendSMS.adapter.RepeatDateAdapter.ViewHolder;
import org.me.SendSMS.data.ContactDetails;
import org.me.SendSMS.data.Model;
import org.me.SendSMS.utli.GlobalVariable;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class ContactAdapter  extends BaseAdapter {
	
	private LayoutInflater mInflater;
	private Context mContext;
	private List<ContactDetails> str;
	List<String> arr = new ArrayList<String>();
	
	
	public ContactAdapter(Context context, List<ContactDetails> list)
	{
		mContext 	= context;
		mInflater 	= LayoutInflater.from(context);
		str = list;
       
	}
	
	public class ViewHolder
	{
		
		TextView txtName;
		TextView txtNumber;
		
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return str.size();
}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	@Override
	public View getView(final int position, View view, ViewGroup parent) {
		// TODO Auto-generated method stub

		final ViewHolder holder;

		if (view == null)
		{
			holder 					= new ViewHolder();
			view 					= mInflater.inflate(R.layout.phone_items, null);
			
			holder.txtName 			= (TextView)view.findViewById(R.id.txtName);
			holder.txtNumber 		= (TextView)view.findViewById(R.id.txtNumber);
			
			view.setTag(holder);
		}
		
		else
		{
			holder = (ViewHolder) view.getTag();
		}

		
		holder.txtName.setTag(position);
		holder.txtNumber.setTag(position);
		
		
		holder.txtName.setText(str.get(position).GetName());
		holder.txtNumber.setText(str.get(position).GetPhone());
		
		
		return view;
	}
}
